home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mac Magazin/MacEasy 19
/
Mac Magazin and MacEasy Magazine CD - Issue 19.iso
/
Online
/
LineShare 3.3.1
/
LineShare Scripts
/
MaxFax&ARA&Data
< prev
next >
Wrap
Text File
|
1995-03-10
|
6KB
|
347 lines
! Version 3.0.4
!
!$ Use this script with Class 2 MaxFax voice software version 3.5 and higher,
!$ ARA 1.0 or 2.0,
!$ and a BBS, E-mail or other communication server software
!
!$ A cable for hardware handshaking is required
^# Modem:
^2 Handshake wires: = Bool("CTS+DTR"="&D0","CTS only"="&D2") "&D2"
^3 Call Progress for Fax: = Bool("Enabled"="","Disabled"="X1") "X1"
! ------------------------------------------
! Resetting the modem:
! ------------------------------------------
@Hangup
SetTries 2
Flush
HsReset 0,0,0,0,0,0
!
! Try to catch the "OK" answer, use the Escape seq and DTR transitions
! to enter the command mode
!
@Label 1
matchclr
matchstr 1 2 "OK\r\n"
write "ATH0V1Q0\r"
matchread 20
ChrDelay 1
Write "+++"
ChrDelay 0
DtrClear
SBreak
DtrSet
!
DecTries
IfTries 0 1
!
! OSErr -6019 "Modem error - the modem is not responding"
!
exit -6019
@Label 2
Write "ATH0\r"
Jsr 100
SetVar A "&F"
GetOption A "DFLT" 3
@Label 3
write "AT^A+FCLASS=0\r"
Jsr 100
exit 0
@Label 6
Say "This script cannot be used with this modem"
ifOriginate 7
pause 1800
@Label 7
exit -6019
! ------------------------------------------
! Receiving incoming calls
! ------------------------------------------
@ANSWER
!
! Set the modem preferred speed first
SerReset 19200,0,8,1
Jsr 80
!
! Set the common options
Jsr 70
@Label 10
MatchClr
Matchstr 1 11 "RING\r\n"
MatchRead 1800
Jump 10
@Label 11
QueueInput "\r\nRING\r\n"
Note "Attaching…" 3
Attach "MaxFax" (Master,DTR)
SetVar D "^$"
Note "Switching…" 3
!
! Set the communication options:
! • Normal (for ARA) /AUTO Connection
! • HW flow control
! • CONNECT <DCE speed> or CARRIER/CONNECT
!
GetOption A "HWHS" 6
GetOption B "NORM" 6
ifStr D 12 "ARA"
GetOption B "AUTO" 6
@Label 12
GetOption C "LNRS" 6
Write "AT^A^B^C+FCLASS=0\r"
Jsr 100
Write "AT+FAA=0\r"
Jsr 100
Write "ATA\r"
Jsr 90
IfStr C 13 "DATA"
exit -6019
@Label 13
ifStr D 30 "ARA"
ifStr D 30 "ARA2"
!
! Regular data connection
!
HsReset 0,1,0,0,0,1
ifStr D 40 "Data"
ifStr D 41 "Data1"
Say "The service '^A' is not supported in the LineShare script"
exit -6019
!
! ARA connection established
!
@Label 30
QueueInput "\r\nCARRIER ^B\r\n"
IfStr A 31 "NONE"
IfStr A 31 "None"
QueueInput "\r\nREL\r\n"
@Label 31
IfOriginate 32
QueueInput "\r\nRING\r\n"
@Label 32
Attach "ARA" (DTR)
! ------------------------------------------
! Originating a call through the "MaxFax" subport
! ------------------------------------------
@ORIGINATE "MaxFax" ("\r\nBusy\r\n")
Note "MaxFax is originating a call ..."
SerReset *
Jsr 80
Jsr 60
HsReset *
Write "AT^3D^1\r"
MatchClr
MatchStr 1 35 "+FCON"
Matchstr 10 82 "BUSY\r\n"
MatchStr 11 83 "NO CARRIER\r\n"
MatchStr 12 84 "NO ANSWER\r\n"
MatchStr 13 81 "NO DIALTONE\r\n"
MatchRead 1200
Exit -6019
@Label 35
QueueInput "\r\n+FCON"
Attach "MaxFax" (DTR)
! ------------------------------------------
! Originating a call through the "ARA" subport
! ------------------------------------------
@ORIGINATE "ARA"
SerReset 19200,0,8,1
Jsr 80
!
! Set the common options
Jsr 70
!
! Set the communication options:
! • Normal Connection
! • HW flow control
! • CONNECT <DCE speed> or CARRIER/CONNECT
!
GetOption A "HWHS" 6
GetOption B "NORM" 6
GetOption C "LNRS" 6
Write "AT^A^B^C\r"
Jsr 100
!
! dial the number
Write "ATD^1\r"
!
! Wait for a modem response
Jsr 90
IfStr C 30 "DATA"
Write "\r"
Exit -6019
! ------------------------------------------
! Originating a call through the "DATA" subports
! ------------------------------------------
@ORIGINATE "Data"
Jsr 45
@Label 40
GetSReg C "Data" 4
Jsr 48
Attach "Data" (DTR,Escape,Break)
@ORIGINATE "Data1"
Jsr 45
@Label 41
GetSReg C "Data1" 4
Jsr 48
Attach "Data1" (DTR,Escape,Break)
@Label 45
Jsr 70
SerReset *
GetOption A "HWHS" 6
GetOption B "AUTO" 6
GetOption C "LNRS" 6
Write "AT^A^B^C\r"
Jsr 60
Write "ATD^1\r"
HsReset *
Jsr 90
IfStr C 46 "DATA"
Write "\r"
Exit -6019
@Label 46
return
@Label 48
QueueInput "\r^CCONNECT ^B\r^C"
IfOriginate 49
QueueInput "\r^CRING\r^C"
@Label 49
return
!
! This section emits all modem commands sent from the client application
! For each set of commands the "OK" answer is awaited
!
@Label 60
EmitStart
@Label 61
EmitCommand 62
Jsr 100
Jump 61
@Label 62
return
!
! This section initiates the modem before ANSWER and ORIGINATEs:
! reset on Dtr drop + DCD valid
! Verbal responses mode, no echo
!
@Label 70
Write "AT^2&C1V1E0\r"
Jsr 100
return
!
! This section syncronize the modem after the serial port speed switching
!
@Label 80
ChrDelay 1
Write "AT\r"
ChrDelay 0
Jsr 100
return
!
! Error codes
@Label 81
exit -6020
@Label 82
exit -6022
@Label 83
exit -6021
@Label 84
exit -6023
!
! This subroutine waits for the modem response
! On exit, ^C contains the result code: "FAX" or "DATA"
! ^A contains the protocol used
! ^B contains the carrier speed
! If modem reports an error, the scripts exits with an error code
!
@Label 90
SetVar C "1200"
ifOriginate 89
SetVar C "600"
@Label 89
SetVar A "NONE"
SetVar B ""
MatchClr
Matchstr 1 92 "CARRIER ^$\r\n"
Matchstr 2 93 "PROTOCOL: ^$\r\n"
Matchstr 3 94 "+FCON"
Matchstr 4 95 "CONNECT ^$/"
Matchstr 5 97 "CONNECT ^$\r\n"
Matchstr 10 82 "BUSY\r\n"
MatchStr 11 83 "NO CARRIER\r\n"
MatchStr 12 84 "NO ANSWER\r\n"
MatchStr 13 81 "NO DIALTONE\r\n"
@Label 91
Matchread Val("^C")
SetVar C "NONE"
return
@Label 92
SetVar B "^$"
Jump 91
@Label 93
SetVar A "^$"
Jump 91
!
! Fax connection was established
!
@Label 94
SetVar C "FAX"
return
! CONNECT xxxx/XXXX was detected
@Label 95
Jsr 98
MatchClr
MatchStr 1 96 "^$\r\n"
MatchRead 10
@Label 96
SetVar A "^$"
SetVar C "DATA"
return
! CONNECT xxx was detected
@Label 97
Jsr 98
SetVar C "DATA"
return
@Label 98
ifStr B 99 ""
return
@Label 99
SetVar B "^$"
return
!
! Processing the AT command:
! OK -> proceed
! ERROR or TimeOut ->exit -6019
! It can be called AFTER the "Write" command, since LineShare buffers input
!
@Label 100
MatchClr
MatchStr 1 102 "OK\r\n"
MatchStr 2 101 "ERROR\r\n"
MatchRead 20
@Label 101
Exit -6019
@Label 102
return